cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

# Set the build type.  Options are:
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
#  Debug          : w/ debug symbols, w/o optimization
#  Release        : w/o debug symbols, w/ optimization
#  RelWithDebInfo : w/ debug symbols, w/ optimization
#  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
#set(ROS_BUILD_TYPE RelWithDebInfo)

rosbuild_init()

#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

# Add the good Leap libraries in lib (depend of the archotecture).
file(GLOB LEAP_BASE "./lib_gen/*.*")
if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
  file(GLOB LEAP_SPEC "./lib_gen/x64/*")
elseif ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "i.86")
  file(GLOB LEAP_SPEC "./lib_gen/x86/*")
endif()

message(STATUS "LEAP_BASE: ${LEAP_BASE}")
message(STATUS "LEAP_SPEC (${CMAKE_SYSTEM_PROCESSOR}): ${LEAP_SPEC}")

foreach (_lib ${LEAP_BASE} ${LEAP_SPEC})
  get_filename_component(LIB_NAME ${_lib} NAME)
  message(STATUS "Current: ${LIB_NAME}")
  add_custom_target(${LIB_NAME} ALL ${CMAKE_COMMAND} -E copy ${_lib} ${LIBRARY_OUTPUT_PATH})
endforeach()

# Add SDK library interface.
file(GLOB HEADER "./include/*/*")
file(GLOB SOURCE "./src/*")
rosbuild_add_library(LeapUtils ${HEADER} ${SOURCE})

# Generate messages.
rosbuild_genmsg()
